//
//  WYCBillController.m
//  51还款
//
//  Created by 中企互联 on 2017/10/30.
//  Copyright © 2017年 中企互联. All rights reserved.
//
#import "WYCBillController.h"
#import "PictureRotate.h"
#import "CCPScrollView.h"
#import "CCZTrotingLabel.h"
#import "WYCMymessegeController.h"
#import "LBBanner.h"
#import "WYCPictureModel.h"
#import "WYCBillModel.h"
#import "WYCHomeCell.h"
#import "WYCBillFrameModel.h"
#import "WYCSeeBillController.h"
#import "WYCHandBillController.h"
#import "WYCUserMessegeModel.h"
#import "WYCMailViewController.h"
#import "WYCAddCreditController.h"
#import "WYCLoginController.h"
#import "WYCmypolicyViewController.h"
#import "FGGAutoScrollView.h"

@interface WYCBillController ()<LBBannerDelegate,UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)FGGAutoScrollView *bannerView;

@property (nonatomic, strong) CCZTrotingLabel *trotView;
//滚动图片数组
@property(nonatomic,strong)NSMutableArray * imageArray;
//滚动图点击链接
@property(nonatomic,strong)NSMutableArray * bannerurlArray;

/** 列表*/
@property(nonatomic,strong)UITableView * tableView;

/** 数组*/
@property(nonatomic,strong)NSMutableArray * billarray;

/** 数组*/
@property(nonatomic,strong)NSMutableArray * userArray;

/** 图片*/
@property(nonatomic,strong)UIImageView * backimg;

/** 提示*/
@property(nonatomic,strong)UILabel * backLabel;

/** 按钮*/
@property(nonatomic,strong)UIButton * ImportButton;

/** view*/
@property(nonatomic,strong)UIView * billView;

/** 背景*/
@property(nonatomic,strong)UIButton * zView;


/** view*/
@property(nonatomic,strong)UIView * ejectView;

@end

@implementation WYCBillController
//-(void)viewWillAppear:(BOOL)animated
//{
//    [super viewWillAppear:animated];
//    [self.tableView.mj_header beginRefreshing];
//
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = WYCGlobalBg;
    //图片数组
     self.imageArray = [[NSMutableArray alloc] init];
    //列表数组
    self.billarray = [[NSMutableArray alloc] init];
    self.userArray = [[NSMutableArray alloc] init];
    self.bannerurlArray = [[NSMutableArray alloc]init];
    
    
    //导航
    [self setupNav];
    //请求消息通知
    [self setusermyMessage];
    
    //创建列表
    [self setupTableView];
    
    
    
    //请求banner图
    [self setBannerLoad];
    [self setupCreditcardlist];
    [self setup];
//    [self createUI];
//
//    __weak typeof(self) wkSelf=self;
//    //调下载完数据后再调用setter方法刷新视图
//    [self downloadDataWithCompletionHandle:^(NSArray *imgsArray){
//        wkSelf.bannerView.imageURLArray=imgsArray;
//    }];
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(setupCreditcardlist)];
}
//初始化
-(void)setup
{
//    self.view.backgroundColor=[UIColor whiteColor];
//    self.title=@"FGGAutoScrollView Demo";
//    self.automaticallyAdjustsScrollViewInsets=NO;
}
////创建自动循环滚动视图
//-(void)createUI
//{
//    //初始化自动循环滚动视图，并且定义图片的点击事件
//    _bannerView=[[FGGAutoScrollView alloc]initWithFrame:CGRectMake(0, NavHeight, ScreenWidth, 550*px) placeHolderImage:nil imageURLs:nil imageDidSelectedBlock:^(NSInteger selectedIndex) {
//
//
//        if (selectedIndex ==0) {
//            //我的保单
//            WYCmypolicyViewController * aboutMe = [[WYCmypolicyViewController alloc] init];
//            [self.navigationController pushViewController:aboutMe animated:NO];
//        }
////        switch (selectedIndex) {
////            case 0:
////                NSLog(@"你选择了第%ld张图片",selectedIndex);
////                //我的保单
////                WYCmypolicyViewController * aboutMe = [[WYCmypolicyViewController alloc] init];
////                [self.navigationController pushViewController:aboutMe animated:NO];
////                break;
////            case 1:
////                NSLog(@"你选择了第%ld张图片",selectedIndex);
////                break;
////            case 2:
////                NSLog(@"你选择了第%ld张图片",selectedIndex);
////                break;
////            default:
////                break;
//      //  }
//    }];
//    //还可以设置自动滚动时的回调事件（可不设置）
//    _bannerView.imageDidScrolledBlock=^(NSInteger index){
//        NSLog(@"滚动到了第%ld张",index);
//    };
//    [self.view addSubview:_bannerView];
//}
////下载数据
//-(void)downloadDataWithCompletionHandle:(void(^)(NSArray *imgsArray))completion
//{
////    //....下载数据...假设下载完得到的数据是array
//   NSArray *array = @[@"http://122.114.70.30:8983/upload/image/20180115/f04323385bef46b98df5ea57a7baa1e9.png",
//                       @"http://122.114.70.30:8983/upload/image/20180115/a7fe835413624a23855e8295286e5e82.png",
//                     @"http://122.114.70.30:8983/upload/image/20180115/9dadc7d686a64d98a30294237ef548d0.png"];
////
////    //完成后调用完成的回调代码块
//    if(completion)
//        completion(array);
//}
-(void)setBannerLoad{
    NSString * str = [NSString stringWithFormat:@"%@",usermyBanner];
    
    [HttpTool POST:str params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        WYCLog(@"---------------%@",responseObject);
        if ([[responseObject objectForKey:@"code"]intValue] == 0) {
            NSArray * resultArray = responseObject[@"result"];
            for (NSDictionary * dict in resultArray) {

                NSString  *bannerUrl = [dict objectForKey:@"bannerUrl"];
                [_bannerurlArray addObject:bannerUrl];
                [_imageArray addObject: [dict objectForKey:@"imgUrl"]];
            }
          [self initImageNamesSystemPageControlAndTitle];

        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];

}
- (void)setusermyMessage{
    NSString * str = [NSString stringWithFormat:@"%@token=%@",usermyMessage,[WYCAccountTool unarchivetoken]];
    [HttpTool POST:str params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"]intValue] == 0) {
            NSArray * resultArray = responseObject[@"result"];
            for (NSDictionary * dict in resultArray) {
                WYCUserMessegeModel * usermodel = [WYCUserMessegeModel mj_objectWithKeyValues:dict];
                [self.userArray addObject:usermodel.content];
            }
            [self showloyout];
        }else{
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
            [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
            [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
            
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}

- (void)showloyout{
    
    //通知的View
    UIView * showView = [[UIView alloc] init];
    showView.backgroundColor = [UIColor whiteColor];
    showView.frame = CGRectMake(0, 550  * px + (NavHeight), ScreenWidth, 120 * px);
    [self.view addSubview:showView];
    
    //通知imageView
    UIImageView *noticeimageView = [[UIImageView alloc] init];
    noticeimageView.frame = CGRectMake(40 * px, 40 * px, 40 * px, 40 * px);
    noticeimageView.image = [UIImage imageNamed:@"提醒"];
    [showView addSubview:noticeimageView];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(noticeimageView.frame) + 30 * px,20 * px, 1, 80 * px)];
    lineView.backgroundColor = WYCbigGrayColor;
    [showView addSubview:lineView];
    
    CCZTrotingLabel *label = [[CCZTrotingLabel alloc] init];
    label.backgroundColor = [UIColor whiteColor];
    label.frame = CGRectMake(CGRectGetMaxX(lineView.frame) + 30 * px, 30 * px, ScreenWidth - noticeimageView.width - 120 * px, 60 * px);
    label.direction = CCZTrotDirectionTop;
    
    self.trotView = label;
    label.repeatTextArr = YES;
    label.hideWhenStopTroting = YES;
    label.pause = 4;
    label.backgroundImage = [UIImage imageNamed:@"1"];
    [label addTextArray:self.userArray];
    [showView addSubview:label];
}
#pragma mark ------>>创建tableview
- (void)setupTableView{
    
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    UIView  *footview = [[UIView alloc]initWithFrame:CGRectMake(0, NavHeight, ScreenWidth, 120 * px)];
    footview.backgroundColor = [UIColor whiteColor];
    footview.userInteractionEnabled = YES;
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 710 * px + (NavHeight), ScreenWidth, ScreenHeight - 710 * px - (NavHeight)) style:UITableViewStylePlain];
    self.tableView.backgroundColor = WYGrayColor;
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    self.tableView.tableFooterView = footview;
    [self.view addSubview:self.tableView];
    
    
    UIButton * cellbutton = [[UIButton alloc] init];
    cellbutton.frame = CGRectMake(0, 0, ScreenWidth, 40);
    cellbutton.titleLabel.font = [UIFont systemFontOfSize:WyzFont];
    [cellbutton setTitleColor:WYCMain forState:UIControlStateNormal];
    cellbutton.contentHorizontalAlignment = UIControlContentVerticalAlignmentCenter;
    [cellbutton addTarget:self action:@selector(addbankButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [cellbutton setTitle:@"+添加信用卡" forState:UIControlStateNormal];
    cellbutton.backgroundColor = [UIColor whiteColor];
    [footview addSubview:cellbutton];
}
-(void)addbankButtonClick
{
    NSLog(@"添加信用卡");
    WYCAddCreditController  *addBank = [[WYCAddCreditController alloc]init];
    [self.navigationController pushViewController:addBank animated:NO];
}
#pragma make ------->>>列表请求
- (void)setupCreditcardlist{
    
    [self.billarray removeAllObjects];
    NSString *cardlist = [NSString stringWithFormat:@"%@token=%@",creditcardlist,[WYCAccountTool unarchivetoken]];
    [HttpTool POST:cardlist params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue ] == 0) {
            NSArray * resultArray = responseObject[@"result"];
            for (NSDictionary * dict in resultArray) {
                
                WYCBillModel * model = [WYCBillModel mj_objectWithKeyValues:dict];
                if ([model.isHideCard isEqualToString:@"1"]) {
                    continue;
                }else{
                WYCBillFrameModel * BillFrameModel = [[WYCBillFrameModel alloc] init];
                BillFrameModel.Billmodel = model;
                
                [self.billarray addObject:BillFrameModel];
                    
                    if (self.billarray.count == 0) {
                        self.tableView.hidden = YES;
                        [self ObtainButton];
                    }else{
                        self.tableView.hidden = NO;
                        [self.billView setHidden:YES];
                    }
                }
            }
        
            
            
        }else{
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
            [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
            [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
        }
        
        [self.tableView reloadData];
        [self.tableView.mj_header endRefreshing];
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        [SVProgressHUD showImage:[UIImage imageNamed:@""] status:Failed];
        [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
        [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
        [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
    }];
    
}
- (void)ObtainButton{
    
    self.billView = [[UIView alloc] init];
    self.billView.frame = CGRectMake(ScreenWidth / 3 , 1000 * px, ScreenWidth / 3 + 100 * px, ScreenWidth / 3);
    self.billView.backgroundColor = WYCGlobalBg;
    [self.view addSubview:self.billView];
    
    _backimg = [[UIImageView alloc] init];
    _backimg.image = [UIImage imageNamed:@"home_bakcimg"];
    _backimg.frame = CGRectMake(0, 0, self.billView.width, self.billView.height - 238 * px);
    [self.billView addSubview:_backimg];
    
    
    _backLabel = [[UILabel alloc] init];
    _backLabel.text = @"还没有账单信息哟~";
    _backLabel.textAlignment = NSTextAlignmentCenter;
    _backLabel.font = [UIFont systemFontOfSize:SmallFont];
    _backLabel.textColor = WYCRGBColor(186, 186, 186);
    _backLabel.frame = CGRectMake(_backimg.x,CGRectGetMaxY(_backimg.frame) + 10 * px,_backimg.width,48 * px);
    [self.billView addSubview:_backLabel];
    
    
    _ImportButton = [[UIButton alloc] init];
    _ImportButton.frame = CGRectMake(_backLabel.x + 50 * px, CGRectGetMaxY(_backLabel.frame) + 80 * px, _backLabel.width - 100 * px , 100 * px);
    [_ImportButton setTitle:@"导入账单" forState:UIControlStateNormal];
    [_ImportButton addTarget:self action:@selector(importClick) forControlEvents:UIControlEventTouchUpInside];
    _ImportButton.backgroundColor = [UIColor whiteColor];
    _ImportButton.titleLabel.font = [UIFont systemFontOfSize:MiddleFont];
    [_ImportButton setTitleColor:WYCRGBColor(195, 195, 195) forState:UIControlStateNormal];
    [self.billView addSubview:_ImportButton];
}

/**
 *  使用本地图片、系统PageControl、设置标题
 */
- (void)initImageNamesSystemPageControlAndTitle {

    
    NSLog(@"轮播图数组%@ %@",_bannerurlArray,_imageArray);
    
    LBBanner * banner = [[LBBanner alloc]initWithImageURLArray:_imageArray andFrame:CGRectMake(0, NavHeight, ScreenWidth, 550*px) ];
    banner.delegate = self;
    
    banner.pageTurnTime = 5;
    banner.pageControlCenter = CGPointMake(ScreenWidth/2, 140);
    [self.view addSubview:banner];
    if (_imageArray[0]) {
            UIView  *navBg = [[UIView alloc]initWithFrame:CGRectMake(0, 40, ScreenWidth, 200)];
            navBg.backgroundColor = [UIColor clearColor];
            navBg.userInteractionEnabled = YES;
            [banner addSubview:navBg];
        UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(alterUrl)];
        //    //给ImageView添加手势
        [banner addGestureRecognizer:singleTap];
    }

}
-(void)alterUrl
{
    //我的保单
    WYCmypolicyViewController * aboutMe = [[WYCmypolicyViewController alloc] init];
    [self.navigationController pushViewController:aboutMe animated:NO];
}
#pragma make ------>>界面布局
- (void)setupNav{
    
    //添加轮播图
    [self setupScrollView];
//    UIImageView *title = [[UIImageView alloc]init];
//    title.frame =CGRectMake(ScreenWidth/2-35, 20, 70, 23);
//    title.image = [UIImage imageNamed:@"name"];
//     self.navigationItem.titleView = title;
    
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
    
    //左侧按钮
//    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"ring" hight:@"ring" target:self action:@selector(photoClick)];
//
//    //右侧按钮
//    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"add" hight:@"add" target:self action:@selector(addClick)];
   
    
}
#pragma make--------->>导入账单
- (void)showClick{
    WYCLogFunc;
    
}
#pragma make ------>>右侧按钮 点击事件
- (void)addClick{
    
    WYCLogFunc;
    
    
    UIView * ejectView = [[UIView alloc] init];
    ejectView.frame = CGRectMake(0, ScreenHeight - 320 * px, ScreenWidth, 320 * px);
    ejectView.backgroundColor = [UIColor whiteColor];
    [[UIApplication sharedApplication].keyWindow  addSubview:ejectView];
    self.ejectView = ejectView;
    
    
    UIButton * zView = [[UIButton alloc] init];
    zView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight - ejectView.height);
    zView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    [zView addTarget:self action:@selector(zviewClick) forControlEvents:UIControlEventTouchUpInside];
    [[UIApplication sharedApplication].keyWindow  addSubview:zView];
    self.zView = zView;

    
    UIButton * holdButton = [[UIButton alloc] init];
    holdButton.frame = CGRectMake(0,  25 * px, ejectView.width, 100 * px);
    [holdButton setTitle:@"手输账单" forState:UIControlStateNormal];
    holdButton.titleLabel.font = [UIFont systemFontOfSize:MiddleFont];
    [holdButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    holdButton.contentHorizontalAlignment =
    UIControlContentHorizontalAlignmentCenter;
    [holdButton addTarget:self action:@selector(holdButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [ejectView addSubview:holdButton];
    
    
    UIView * line = [[UIView alloc] init];
    line.backgroundColor = WYCGlobalBg;
    line.frame = CGRectMake(0, CGRectGetMaxY(holdButton.frame) + 25 * px, ejectView.width, 20 * px);
    [ejectView addSubview:line];
    
    
    UIButton * NoButton = [[UIButton alloc] init];
    NoButton.frame = CGRectMake(0, CGRectGetMaxY(line.frame) + 25 * px, ejectView.width, 100 * px);
    [NoButton setTitle:@"取消" forState:UIControlStateNormal];
    NoButton.titleLabel.font = [UIFont systemFontOfSize:MiddleFont];
    [NoButton addTarget:self action:@selector(NoButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [NoButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    NoButton.contentHorizontalAlignment =
    UIControlContentHorizontalAlignmentCenter;
    [ejectView addSubview:NoButton];
    
}
- (void)maillButtonClick{
    self.zView.hidden = YES;
    self.ejectView.hidden = YES;
    WYCMailViewController  *mailView = [[WYCMailViewController alloc]init];
    [self.navigationController pushViewController:mailView animated:YES];
}

- (void)holdButtonClick{
    WYCLogFunc;
    self.zView.hidden = YES;
    self.ejectView.hidden = YES;
    WYCHandBillController * handbill = [[WYCHandBillController alloc] init];
    [self.navigationController pushViewController:handbill animated:NO];
}

- (void)NoButtonClick{
    WYCLogFunc;
    self.zView.hidden = YES;
    self.ejectView.hidden = YES;
    
}
- (void)zviewClick{
    WYCLogFunc;
    self.zView.hidden = YES;
    self.ejectView.hidden = YES;
}
#pragma make ------>>左侧按钮 点击事件
- (void)photoClick{
    WYCMymessegeController * mymessege = [[WYCMymessegeController alloc] init];
    [self.navigationController pushViewController:mymessege animated:NO];
}
#pragma make ------>>最上侧轮播图
- (void)setupScrollView {
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (self.billarray.count>0) {
        return self.billarray.count;
    }
    else{
    return 1;
    }
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 150;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    static NSString * strID = @"cell";
    
    WYCHomeCell * cell = [tableView dequeueReusableCellWithIdentifier:strID];
    
    if (cell == nil)
    {
        
        cell=[[[NSBundle mainBundle]loadNibNamed:@"WYCHomeCell" owner:self options:nil]lastObject];
        
    }
    if (self.billarray.count>0) {
        cell.billmodelFrame = self.billarray[indexPath.row];

    }else
    {
    cell.userInteractionEnabled = NO;
    }
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.backgroundColor = [UIColor clearColor];
    if ([cell.repaymentButton.titleLabel.text isEqualToString:@"立即认证"]) {
        [cell.repaymentButton addTarget:self action:@selector(repayMentClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    WYCBillFrameModel * frameModel = self.billarray[indexPath.row];
    
    if ([frameModel.Billmodel.approve isEqualToString:@"2"]) {
        
        return;
    }else{
        
        WYCSeeBillController * SeeBill = [[WYCSeeBillController alloc] init];
        //银行卡账号
        SeeBill.cardId = frameModel.Billmodel.cardId;

        //银行卡姓名
       SeeBill.bankName = frameModel.Billmodel.bankName;

        //银行卡后四位
        SeeBill.lastNumber = frameModel.Billmodel.lastNumber;

        //银行卡多少天出账单
        SeeBill.outbBllDay = frameModel.Billmodel.outbBllDay;

        //本期账单金额
        SeeBill.billAmount = frameModel.Billmodel.billAmount;


        //免息期
        SeeBill.gracePeriod = frameModel.Billmodel.gracePeriod;

        
        //总额度
        SeeBill.creditLine = frameModel.Billmodel.creditLine;


        //还款日
        SeeBill.dueDate = frameModel.Billmodel.dueDate;


        //账单日
      SeeBill.billDate = frameModel.Billmodel.billDate;


        SeeBill.userCard = frameModel.Billmodel.userCard;
        SeeBill.bankType = frameModel.Billmodel.state;
        
//
        [self.navigationController pushViewController:SeeBill animated:NO];
    }
}
//导入账单
- (void)importClick{
    
    [self addClick];
}
- (void)repayMentClick{
    
    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"绑定成功！请耐心等待认证结果或拨打客服电话咨询"];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
    [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    
    [self.tableView.mj_header beginRefreshing];
    
    self.navigationController.navigationBar.hidden = YES;
    
    
    UIView * NavView = [[UIView alloc] init];
    NavView.frame = CGRectMake(0, 0, ScreenWidth, NavHeight);
    NavView.backgroundColor = WYCMain;
    [self.view addSubview:NavView];
    
    
    
    CALayer *bottomLineLayer = [[CALayer alloc] init];
    bottomLineLayer.frame = CGRectMake(0, NavView.bounds.size.height - 0.5, NavView.bounds.size.width, 0.5);
    bottomLineLayer.backgroundColor = WYCMain.CGColor;
    [NavView.layer addSublayer:bottomLineLayer];
    
    
    //返回按钮
    UIButton *  backbutton = [[UIButton alloc] init];
    [backbutton setImage:[UIImage imageNamed:@"add"] forState:UIControlStateNormal];
    [backbutton addTarget:self action:@selector(importClick) forControlEvents:UIControlEventTouchUpInside];
    backbutton.frame = CGRectMake(NavView.width - 96 * px, titleY, 70 * px , 70 * px);
    [NavView addSubview:backbutton];
    
    
    //返回按钮
    UIButton *  fanhuibutton = [[UIButton alloc] init];
    [fanhuibutton setImage:[UIImage imageNamed:@"ring"] forState:UIControlStateNormal];
    [fanhuibutton addTarget:self action:@selector(photoClick) forControlEvents:UIControlEventTouchUpInside];
    fanhuibutton.frame = CGRectMake(30 * px, titleY, 66 * px , 66 * px);
    [NavView addSubview:fanhuibutton];
    
    int H;
    if (NavHeight == 64) {
        H = 20;
    }else{
        H = 35;
    }
    UIImageView *title = [[UIImageView alloc]init];
        title.frame =CGRectMake(ScreenWidth/2-35, titleY, 70, 25);
        title.image = [UIImage imageNamed:@"name"];
    [NavView addSubview:title];
}
- (void)backClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end
